package com.power.home.net.okHttp;

import android.util.Log;

import com.power.home.common.Constant;
import com.power.home.common.apkUpdate.AppUtils;
import com.power.home.net.okHttp.client.CommonOkHttpClient;
import com.power.home.net.okHttp.listener.DisposeDataHandle;
import com.power.home.net.okHttp.listener.DisposeDataListener;
import com.power.home.net.okHttp.request.CommonRequest;
import com.power.home.net.okHttp.request.RequestParams;

import cn.jiguang.net.HttpConstants;

public class RequestCenter {

    static class HttpContants {
        private static final String VERIFY_URL = "http://apis.juhe.cn/idimage/verify";

        private static final String UPDATE_URL = Constant.BASE_URL+"/api/appversion/checkAppVersion";
    }
    //根据参数发送所有post请求
    public static void postRequest(String url, RequestParams params, DisposeDataListener listener,
                                   Class<?> clazz){
        CommonOkHttpClient.post(CommonRequest.
                createPostRequest(url, params), new DisposeDataHandle(listener, clazz));
    }

    public static void getRequest(String url,RequestParams params,DisposeDataListener listener,Class<?> clazz){
        CommonOkHttpClient.get(CommonRequest.createGetRequest(url,params),new DisposeDataHandle(listener,clazz));
    }
    public static void requestPersonVerifyinfo(DisposeDataListener listener,RequestParams params){

        RequestCenter.postRequest(HttpContants.VERIFY_URL,params,listener,null);

    }

    public static void requestUpdateInfo(DisposeDataListener listener){
        Log.i("程序版本",AppUtils.getVersionName());
        RequestParams params = new RequestParams();
        params.put("client","ANDROID");
        params.put("channel","appstore");
        params.put("version", AppUtils.getVersionName());
        RequestCenter.getRequest(HttpContants.UPDATE_URL,params,listener,null);
    }
}

